package com.fulihui.wgj.admin.api.subscribeuser;

import com.fulihui.common.builder.web.JsonResultBuilder;
import com.fulihui.common.result.web.PageView;
import com.fulihui.common.result.web.Result;
import com.fulihui.wgj.admin.api.base.BaseController;
import com.fulihui.wgj.admin.api.subscribeuser.request.SubscribeUserReq;
import com.fulihui.wgj.admin.api.subscribeuser.vo.SubscribeUserVO;
import com.fulihui.wgj.admin.integration.SubscribeUserClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Objects;

/**
 * @author: JY
 * @date: 2018/7/5 11:00
 * 关注人数
 */
@RestController
@RequestMapping("/subscribeUser")
@Api(tags = "关注人数接口")
public class SubscribeUserController extends BaseController {

    @Autowired
    SubscribeUserClient subscribeUserClient;

    @ApiOperation(value = "关注人数列表")
    @PostMapping("/list")
    public Result<PageView<SubscribeUserVO>> list(@RequestBody @Valid SubscribeUserReq userReq, BindingResult validResult, HttpServletRequest request) {

        Result result = valid(validResult);
        if (Objects.nonNull(result)) {
            return result;
        }

        userReq.setAppId(getAppid(request));
        PageView<SubscribeUserVO> list = subscribeUserClient.list(userReq);

        return JsonResultBuilder.succ(list);
    }

}
